/**
 * 封装网站数据浏览器存储类
 */
//固定空间 所有数据存储再此空间中 其余在细分
//由于太多移除默认空间有参数传递过来
//let nameSpace="MyCustom"
export default {
  getStorage(key) {
    let str = window.localStorage.getItem(key) || '{}';
    let j_json = eval('(' + str + ')');
    return j_json;
  },
  setItem(key, val) {
    let storage = this.getStorage(key);
    window.localStorage.setItem(key, JSON.stringify(val));
  },
  getItem(key) {
    return this.getStorage(key);
  },
  //清空数据
  clearItem(key) {
    let storage = this.getStorage(key);
    window.localStorage.removeItem(key);
  },
  clearAll() {
    window.localStorage.clear(key);
  },
  hasKey(key) {
    if (localStorage.getItem(key) != null) {
      return true;
    }
    return false;
  },
};
